{extend name="base"/}
{block name="resources"}
<style type="text/css">
    .no-auth{padding: 100px 0;text-align: center;}
</style>
{/block}
{block name="main"}
{if isset($auth_info['code']) && $auth_info['code'] == 0}
    {if $sync_status == 1}
    <div class="layui-collapse ns-tips">
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">操作提示</h2>
            <ul class="layui-colla-content layui-show">
                <li>您的授权证书与官网最新的授权证书存在差异，为保证您的系统的正常运行，请手动点击下方按钮更新证书。</li>
            </ul>
        </div>
    </div>
    <div class="ns-single-filter-box">
        <button class="layui-btn ns-bg-color" id="syncCert" onclick="syncCert()">更新证书</button>
    </div>
    {/if}

    <div class="index-box">
        <div class="index-content">
            <div class="system-function">
                <table class="layui-table">
                    <colgroup>
                        <col width="20%">
                        <col width="30%">
                        <col width="20%">
                        <col width="30%">
                    </colgroup>
                    <tbody>
                    <tr>
                        <td class="ns-bg-color-light-gray">产品名称</td>
                        <td>{$auth_info['data']['product_name']}</td>
                        <td class="ns-bg-color-light-gray">授权状态</td>
                        <td>已授权</td>
                    </tr>
                    <tr>
                        <td class="ns-bg-color-light-gray">授权码</td>
                        <td>{$auth_info['data']['devolution_code']}</td>
                        <td class="ns-bg-color-light-gray">授权版本</td>
                        <td>{$auth_info['data']['devolution_version_name']}</td>
                    </tr>
                    <tr>
                        <td class="ns-bg-color-light-gray">当前版本</td>
                        <td>{$app_info.version}</td>
                        <td class="ns-bg-color-light-gray">最新版本</td>
                        <td>{$auth_info['data']['newest_version']}</td>
                    </tr>
                    <tr>
                        <td class="ns-bg-color-light-gray">授权时间</td>
                        <td>{:date('Y-m-d H:i:s', $auth_info['data']['devolution_date'])}</td>
                        <td class="ns-bg-color-light-gray">服务到期时间</td>
                        <td>
                            {:date('Y-m-d H:i:s', $auth_info['data']['devolution_expire_date'])}
                            {if condition="$auth_info['data']['devolution_expire_date'] > $my_auth_info['expire_time']"}
                            <span style="color:red;">可更新</span>
                            {/if}
                        </td>
                    </tr>
                    <tr>
                        <td class="ns-bg-color-light-gray">授权归属</td>
                        <td>{$auth_info['data']['devolution_attribution']}</td>
                        <td class="ns-bg-color-light-gray">授权域名</td>
                        <td>{$auth_info['data']['devolution_url']}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{else/}
<div class="index-box">
    <div class="index-content">
        <div class="system-function">
            <table class="layui-table">
                <colgroup>
                    <col width="20%">
                    <col width="30%">
                    <col width="20%">
                    <col width="30%">
                </colgroup>
                <tbody>
                <tr>
                    <td class="ns-bg-color-light-gray">产品名称</td>
                    <td>SaaSV4</td>
                    <td class="ns-bg-color-light-gray">授权状态</td>
                    <td>未授权 <a href="https://www.niushop.com" class="ns-text-color" target="_blank">去授权</a> </td>
                </tr>
                <tr>
                    <td class="ns-bg-color-light-gray">套餐版本</td>
                    <td>免费版</td>
                    <td class="ns-bg-color-light-gray">当前版本</td>
                    <td>{$app_info.version}</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
{/if}
{/block}
{block name="script"}
<script>
    //同步证书
    function syncCert(){
        $.ajax({
            type: "POST",
            dataType: 'JSON',
            url: ns.url("admin/upgrade/syncCert"),
            success: function(res) {
                if (res.code > 0) {
                    layer.msg('操作成功');
                    location.reload();
                } else {
                    layer.msg(res.message)
                }
            }
        });
    }
</script>
{/block}
